import {Component, OnInit, ViewChild} from '@angular/core';
import {ListService} from "../services/list.service";

@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit{

  jishus:Array<string> = [];

  constructor(private listService:ListService){
    //通过服务注入
    this.jishus = this.listService.getList();
  }

  title:string = '理赔项目';

  list:Array<string> = ['java','oracle'];

  /**
   * 父组件调用子组件公开的方法
   */
  @ViewChild('titleDom')
  child:any;

  /**
   * 调用子组件方法
   */
  addBtnFun1(){
    console.log(this.child.title);
    this.child.addBtnFun();
  }

  /**
   * 调用服务方法
   */
  addBtnFun2(){
    console.log(this.child.title);
    this.jishus.push('query');
  }

  addListFun(str:string){
    this.list.push(str);
  }

  ngOnInit(): void {

  }

  changeTitle(){
    this.title = '承保项目';
  }

}
